#ifndef FONT_MATERIAL_H_
#define FONT_MATERIAL_H_

#include "ft2build.h"
#include FT_FREETYPE_H

#include "material.h"

class CFontCharacter
{
	
public:
	
	Vector2D m_Size, m_CoordMul;
	int m_Trans;
	int m_Down, m_Left;
	
};

class CFontMaterial : public CMaterial
{

private:

	GLuint * m_Textures, m_DList;
	int m_Height;
	int * m_XTrans;
	
	CFontCharacter * m_FontCharacters;

public:
	
	CFontMaterial() : CMaterial()
	{
		
		m_XTrans = NULL;
		m_Textures = NULL;
		m_FontCharacters = NULL;
		
	}

	void LoadFromFile( std::string );
	
	void DrawCharacter( char );
	
	inline void SetHeight( int h )
	{
		
		m_Height = h;
		
	}
	
	inline int GetHeight()
	{
		
		return m_Height;
		
	}
	
	inline int GetStringWidth( std::string s )
	{
		
		if( m_XTrans == NULL )
			return 0;
		
		int w = 0;
		
		for( int j = 0; j < s.length(); j++ )
		{
			
			if( s[j] >= 0 && s[j] < 256 )
				w += m_XTrans[s[j]];
			
		}
		
		return w;
		
	}
	
	void Draw( std::string, double, double );
	
	virtual ~CFontMaterial();

};

void InitFreeTypeLibrary();
void CleanFreeTypeLibrary();

#endif
